﻿
(function ($) {
    $.fn.showimg = function () {  
        if ($('#myModal').length == 0) {
            createEle('myModal');
            $('#myModal').addClass('modal');
        }
        var html = "<span class=\"close\" onclick=\"document.getElementById('myModal').style.display = 'none'\">&times;</span>'"
            + "<img class=\"modal-content\" src=\"" + this[0].src + "\">"
            + "<div class=\"caption\">" + this[0].alt + "</div>";  
        $("#myModal").html(html).show(); 
    };

})(jQuery);

var showImg = function (item) {
    $(item).showimg(); 
};
var createEle = function (elementId) {
    var parentNode = document.getElementsByTagName('body');
    var sonNode = document.createElement('div');
    var sonNodeId = document.createAttribute('id');
    sonNodeId.value = elementId;
    sonNode.setAttributeNode(sonNodeId); 
    parentNode[0].appendChild(sonNode);
}